#include "shapeview.h"
#include <QMouseEvent>

ShapeView::ShapeView(QWidget *parent) : QSFMLCanvas(parent)
{
    currentShape = 0;
}

void ShapeView::mouseReleaseEvent(QMouseEvent* event)
{
    if (event->button() == Qt::LeftButton)
        Clicked(GetAbsolutePosFromClick(event));
    else
        QSFMLCanvas::mouseReleaseEvent(event);
}

void ShapeView::SetTexture(const sf::Texture &texture)
{
  Shiny::SpriteAnimate::AnimationArray array;
  Shiny::SpriteAnimate::Animation      animation(&texture);

  array.push_back(animation);
  currentSprite.SetPosition(0.f, 0.f);
  currentSprite.SetAnimations(array);
}

void ShapeView::AddShape(sf::Shape *shape)
{
    shapes << shape;
}
